Adding support of map_top_n_values to Presto#18607
Merged
kaikalur merged 1 commit intoprestodb:masterfrom Nov 16, 2022
Merged
Conversation
Contributor
|
See my comments in the other one - MAP_TOP_N_KEYS - same applies here - just do it as a SQL udf |
50669cd to
be3de66
Compare
Contributor
Author
Cool! Let me do this a SQL UDFs |
7ab8e9c to
8330da3
Compare
Contributor
Author
kaikalur
requested changes
Nov 8, 2022
presto-main/src/main/java/com/facebook/presto/operator/scalar/sql/MapSqlFunctions.java
Outdated
Show resolved
Hide resolved
8330da3 to
8c5bdaa
Compare
kaikalur
approved these changes
Nov 10, 2022
Contributor
|
Also squash the commits |
|
Same comment as the other PR..... The release note is too verbose. We only need one (long) line to explain what it does in English. Also, we need |
4ed5a4b to
8c0c365
Compare
185df62 to
325a872
Compare
Contributor
Author
Done! |
Contributor
Author
|
Can we merge this PR? |
30 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add an UDF for getting top N values of a map, which returns an array of the top N values of map. Optionally a lambda comparator can also be passed to perform a custom comparison of the values. Returns all the value if the value N is greater than or equal to size of the map. N must be >= 0. For N = 0, the function returns empty array.
map_top_n_values(map(K, V), N) -> array(V)
map_top_n_values(map(K, V), N, function(V, V, int)) -> array(V)
Return the top N values of the map sorted using the lambda comparator.
Test plan - (Please fill in how you tested your changes)
Added unit tests.
Build successfully using the following terminal command
./mvnw clean install -Dtest=TestMapTopValuesFunction -fn -pl presto-main./mvnw clean install -Dtest=TestMapTopValuesComparatorFunction -fn -pl presto-main